package com.leyou.common.advice;

import com.leyou.common.exception.LyException;
import com.leyou.common.vo.ResultVO;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @program: leyou
 * @description: 通用异常处理切面
 * @author: NieMiao
 * @create: 2018-11-02 11:47
 **/
@ControllerAdvice
public class CommonExceptionHandler {

    @ExceptionHandler(LyException.class)
    public ResponseEntity<ResultVO> handlerException(LyException e){
        return ResponseEntity.status(e.getExceptionEnum().getStatus())
                .body(new ResultVO(e.getExceptionEnum()));
    }
}
